<?php
namespace Controller;

use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Container;

class User extends Base
{
    public function __construct(Container $container)
    {
        parent::__construct($container);
    }

    public function index()
    {

        $count=$this->db->find('tcp_account');
        if(empty($count)){
            $is_create=0;
        }else{
            $is_create=1;
        }
        $this->guard->generateToken();
        $this->assign= [
            'tk_name' => $this->guard->getTokenName(),
            'tk_value' => $this->guard->getTokenValue(),
            'is_create'=>$is_create
        ];
        $this->view->assign($this->assign);
        $this->view->display('admin/login.html');
    }
    public  function loginout(Request $req, Response $res){
        unset($_SESSION['account_id']);
        return $res->withRedirect('/admin/login');
        exit;

    }


}